﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using HR.Appointments.Service.ValueObjects;

namespace HR.Appointments.Service.Test
{
    [TestFixture]
    public class TestOpenHours
    {
        [SetUp]
        public void SetUp()
        {
            MockDao.SetUp();
        }

        [TearDown]
        public void TearDown()
        {
            MockDao.TearDown();
        }

        [Test]
        public void ObjectIsEqual()
        {
            var openHours1 = DAO.Instance.OpenHours.GetByDate(1, TestVariables.Date);
            var openHours2 = DAO.Instance.OpenHours.GetByDate(1, TestVariables.Date);
            Assert.AreEqual(openHours1, openHours2);
        }

        [Test]
        public void MockLoad()
        {
            var openHours = DAO.Instance.OpenHours.GetByDate(1, TestVariables.Date);
            Assert.IsNotNull(openHours);
            Assert.AreEqual(openHours.FromTime, TimeUnit.Create(8, 0));
            Assert.AreEqual(openHours.ToTime, TimeUnit.Create(17, 0));
            Assert.AreEqual(openHours.DayId, 1);
            Assert.AreEqual(openHours.CompanyId, 1);
        }

        [Test]
        public void GetTimeSlots()
        {
            var openHours = DAO.Instance.OpenHours.GetByDate(1, TestVariables.Date);
            List<TimeUnit> timeSlots = openHours.GetTimeSlots();

            Assert.AreEqual(18, timeSlots.Count);
            Assert.AreEqual(TimeUnit.Create(8,0), timeSlots[0]);
            Assert.AreEqual(TimeUnit.Create(8, 30), timeSlots[1]);
            Assert.AreEqual(TimeUnit.Create(9, 0), timeSlots[2]);
            Assert.AreEqual(TimeUnit.Create(9, 30), timeSlots[3]);
            Assert.AreEqual(TimeUnit.Create(10, 0), timeSlots[4]);
            Assert.AreEqual(TimeUnit.Create(10, 30), timeSlots[5]);
            Assert.AreEqual(TimeUnit.Create(11, 0), timeSlots[6]);
            Assert.AreEqual(TimeUnit.Create(11, 30), timeSlots[7]);
            Assert.AreEqual(TimeUnit.Create(12, 0), timeSlots[8]);
            Assert.AreEqual(TimeUnit.Create(12, 30), timeSlots[9]);
            Assert.AreEqual(TimeUnit.Create(13, 0), timeSlots[10]);
            Assert.AreEqual(TimeUnit.Create(13, 30), timeSlots[11]);
            Assert.AreEqual(TimeUnit.Create(14, 0), timeSlots[12]);
            Assert.AreEqual(TimeUnit.Create(14, 30), timeSlots[13]);
            Assert.AreEqual(TimeUnit.Create(15, 0), timeSlots[14]);
            Assert.AreEqual(TimeUnit.Create(15, 30), timeSlots[15]);
            Assert.AreEqual(TimeUnit.Create(16, 0), timeSlots[16]);
            Assert.AreEqual(TimeUnit.Create(16, 30), timeSlots[17]);
        }
    }
}
